//
//  CDOCRViewController.swift
//  PDF
//
//  Created by Kellv on 2024/4/21.
//

import UIKit

class CDOCRViewController: CDBaseAllViewController {
    var titelLabel:UILabel!

    var textView: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()
        let leftBtn = UIButton(type: .custom)
        leftBtn.frame = CGRect(x: 16, y: 16, width: 80, height: 32)
        leftBtn.titleLabel?.font = UIFont(name: "HelveticaNeue-Bold", size: 12)
        leftBtn.layer.cornerRadius = 16
        leftBtn.setTitle("English", for: .normal)
        leftBtn.backgroundColor = UIColor(red: 0.255, green: 0.443, blue: 1, alpha: 0.15)
        leftBtn.addTarget(self, action: #selector(onLeftAction), for: .touchUpInside)
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBtn)
        
        titelLabel = UILabel(frame: CGRect(x: CDSCREEN_WIDTH - 16 - 48, y: 16, width: 48, height: 32))
        titelLabel.textColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
        titelLabel.font = UIFont(name: "Helvetica-Bold", size: 14)
        titelLabel.backgroundColor = UIColor(hexStr: "7F89A1")
        titelLabel.textAlignment = .center
        titelLabel.text = "0/0"
        titelLabel.addRadius(corners: .allCorners, size: CGSize(width: 16, height: 16))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: titelLabel)
        
        let optionsview = CDEditBarToolsView(frame: CGRect(x: 0, y: view.height - 80, width: CDSCREEN_WIDTH, height: 80), types: [.redo,.copy,.doDocx,.export])
        view.addSubview(optionsview)
        optionsview.didSelectHanlder = {[weak self] option in
            guard let self = self else {
                return
            }
        
        }
        
        textView = UITextView(frame: CGRect(x: 0, y: 0, width: CDSCREEN_WIDTH, height: optionsview.minY))
        self.view.addSubview(textView)
    }
    
    func didSelect(option: CDTextEditOptions) {
        switch option {
        case .redo:
            self.dismiss(animated: true)
        case .copy:
            UIPasteboard.general.string = textView.text
        case .doDocx: break
        case .export: break
        default:break
        }
    }
    @objc func onLeftAction() {
        
    }
        /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
